<%@ page import="sky.domain.Flight" %>
<%@ page import="java.text.SimpleDateFormat" %>
<%@ page import="java.util.Date" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
    SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    SimpleDateFormat formatter2 = new SimpleDateFormat("dd.MM.yyyy");
    SimpleDateFormat formatter3 = new SimpleDateFormat("HH:mm");
    Date date = formatter.parse(((Flight)request.getAttribute("flight")).getDepartureDate().toString());
    Date date1 = formatter.parse(((Flight)request.getAttribute("flight")).getDestinationDate().toString());
%>
<div class="flightInfo">
    <div class="flightInfoHeader">
        <span class="flightInfoHeader" style="width: 12px">${flight.id}</span>
        <span class="flightInfoHeader" style="width: 90px">${flight.departureAirport.name}</span>
        <span class="flightInfoHeader" style="width: 150px"><%= formatter2.format(date) %></span>
        <span class="flightInfoHeader" style="width: 10px">-</span>
        <span class="flightInfoHeader" style="width: 90px">${flight.destinationAirport.name}</span>
        <span class="flightInfoHeader" style="width: 65px" ></span>
        <span class="flightInfoHeader">
            <span class="expand">[v]</span>
            <c:if test="${showAuth == 2}">
                <a href="/flights/edit/${flight.id}">[7]</a>
                <a href="/flights/delete/${flight.id}">[x]</a>
            </c:if>
        </span>
    </div>
    <div class="flightInfoContent">
        <div class="left">
            <p><spring:message code="flightInfo.airport" />:
                <a href="
                    <c:url value="/airport">
                        <c:param name="id" value="${flight.departureAirport.id}" />
                    </c:url> ">
                ${flight.departureAirport.name}</a>
            </p>
            <p><spring:message code="flightInfo.city" />:
                <a href="
                    <c:url value="/city">
                        <c:param name="id" value="${flight.departureAirport.city.id}" />
                    </c:url> ">
                ${flight.departureAirport.city.name}</a>
            </p>
            <p><spring:message code="flightInfo.country" />:
                <a href="
                    <c:url value="/country">
                        <c:param name="id" value="${flight.departureAirport.city.country.id}" />
                    </c:url> ">
                    ${flight.departureAirport.city.country.name}</a>
            </p>
            <p><spring:message code="flightInfo.DepDate" />: <%= formatter2.format(date) %></p>
            <p>Time: <%= formatter3.format(date) %></p>
        </div>
        <div class="right">
            <p><spring:message code="flightInfo.airport" />:
                <a href="
                    <c:url value="/airport">
                        <c:param name="id" value="${flight.destinationAirport.id}" />
                    </c:url> ">
                    ${flight.destinationAirport.name}</a>
            </p>
            <p><spring:message code="flightInfo.city" />:
                <a href="
                    <c:url value="/city">
                        <c:param name="id" value="${flight.destinationAirport.city.id}" />
                    </c:url> ">
                ${flight.destinationAirport.city.name}</a>
            </p>
            <p><spring:message code="flightInfo.country" />:
                <a href="
                    <c:url value="/country">
                        <c:param name="id" value="${flight.destinationAirport.city.country.id}" />
                    </c:url> ">
                    ${flight.destinationAirport.city.country.name}</a>
            </p>
            <p><spring:message code="flightInfo.DesDate" />: <%= formatter2.format(date1) %></p>
            <p>Time: <%= formatter3.format(date1) %></p>
        </div>
        <div class="sub">
            <p><spring:message code="flightInfo.plane" />:
                <a href="
                    <c:url value="/plane">
                    <c:param name="id" value="${flight.plane.id}" />
                    </c:url>">
                    ${flight.plane.name}</a></p>
            <p><spring:message code="flightInfo.places" />: ${flight.freeEconomPlaces}|${flight.freeBussinessPlaces}|${flight.freeFirstClassPlaces}</p>
            <p><spring:message code="flightInfo.minCost" />: ${flight.economCost}|${flight.bussinessCost}|${flight.firstClassCost}</p>
        </div>
    </div>
</div>